<!DOCTYPE html>
<html>
<head>
	{include file='top.tpl'}
	{literal}
	<style>
		.form-control{display: inline-block;width:auto;}
	</style>
	{/literal}
</head>
<body class="skin-blue">
<div class="wrapper">
	{include file="bread_crumbs.tpl"}
	<!--引入面包屑-->
	<section class="web-setting-wrap">
		<div class="row">
			<div class="col-md-12">
				<div class="box">
	                <div class="box-header with-border clearfix">
	                	<div class="box-form pull-right form-group-sm">
	                		<p class="pull-right"><a href="javascript:;" class="btn btn-success btn-sm" id="js_toggleSearchBox"><i class="fa fa-search"></i><span class="pl5">搜索选项</span></a></p>
	                		<a class="btn btn-primary btn-sm pull-right" href="javascript:;" id="sync_all_user">同步用户</a>
	                	</div>
	                	<div class="clearfix"></div>
						<div class="search-box" id="js_searchBox">
							<form action="/system/user/index/" method="get">
								<div class="form-group-sm">
									<p>								
										<label class="control-label">分类：</label>
										<select id="cat_id" deval='{$params.deval}' style="font-size:12px;font-family:;microsoft YaHei;"></select>
										<input type="hidden" name="select_cat_id" id="select_cat_id"/>&nbsp;
										<label class="control-label">部门：</label>
										<select id="dept_id" deval="{$params.dept_path}" data-dept='{$params.dept_id}' style="font-size:12px;font-family:;microsoft YaHei;"></select>
										<input type="hidden" name="select_dept_id" id="select_dept_id"/>&nbsp;
									</p>
									<p class="no-margin">
										<label class="control-label">用户名：</label>
										<input type="text" class="form-control" name='keyword' value='{$params.keyword}'/>
	                					<label class="control-label">是否组长：</label>
										<select class="form-control" name='is_group_leader'>
											<option value="">请选择</option>
		                					<option value="1" {if isset($smarty.get.is_group_leader) and ($smarty.get.is_group_leader eq '1')}selected="selected"{/if}>是</option>
	                       					<option value="0" {if isset($smarty.get.is_group_leader) and ($smarty.get.is_group_leader eq '0')}selected="selected"{/if}>否</option>
	                					</select>
	                					<label class="control-label">用户状态：</label>
										<select class="form-control" name='is_enable'>
											<option value="">请选择</option>
		                					<option value="1" {if isset($smarty.get.is_enable) and ($smarty.get.is_enable eq '1')}selected="selected"{/if}>启用</option>
	                       					<option value="0" {if isset($smarty.get.is_enable) and ($smarty.get.is_enable eq '0')}selected="selected"{/if}>禁用</option>
	                					</select>
	                					<label class="control-label">角色</label>
	                					<select  class="form-control" name='role_id'>
		                					<option value="0">请选择</option>
			                				{if count($roles)>0}
	                       					{foreach from=$roles item=role}
	                       					<option value="{$role.role_id}" {if $params.role_id==$role.role_id} selected="selected" {/if}>{$role.role_name}</option>
	                       					{/foreach}
	                       					{/if}
		                				</select>
										<button type="submit" id="search_button" class="btn btn-primary btn-sm">立即搜索</button>
									</p>
	                			</div>
	                		</form>
	                	</div>
	                </div><!-- /.box-header -->
	                <div class="box-body">
	                  <table class="table table-bordered table-striped table-hover">
	                    <thead>
		                    <tr>
		                      <th width="100" data-field="op_operation">操作</th>
		                      <th data-field="id">序号</th>
		                      <th data-field="username">用户名</th>
		                      <th data-field="name">姓名</th>
		                      <th data-field="department">所属部门</th>
		                      <th data-field="role">所属角色</th>
		                      <th data-field="op_people">操作人</th>
		                      <th data-field="op_time">操作时间</th>
		                    </tr>
	                    </thead>
	                    <tbody>
	                    {if count($users)>0}
                        {foreach from=$users key=key item=data}
		                    <tr>
		                      <td>
		                      	<a href="/system/user/setprivilege?id={$data.user_id}" class="btn btn-primary btn-sm" data-toggle="tooltip" data-original-title="编辑用户权限"><i class="fa fa-key"></i></a>                    	
		                      </td>
								<td>{$data.user_id}</td>
								<td>{$data.user_name}</td>
								<td>{$data.real_name}</td>
								<td>{$data.detp_name}</td>
								<td>{$data.role_name}</td>
								<td>{$data.update_user}</td>
								<td>{$data.update_time}</td>
		                    </tr>
		                    {/foreach}
                        {/if}
	                    </tbody>	                    
	              	</table>
	                </div>
	                <!-- .box-body -->
	                <div class="box-footer text-center clearfix">{$page_link}</div>
	            </div>
			</div>
		</div>
	</section>
</div>
{include file='foot.tpl'}
{literal}
<script>
	var str = $("#cat_id").attr('deval');
	var s = $("#dept_id").attr('deval');

	var opts = {
		ajax: '/widget/category/getcat',
		selClass:'form-control inline',
		selStyle: 'font-size:12px;font-family:;microsoft YaHei;',
		autoLink : false,
		defVal: str.split(','),
		head: '请选择产品分类',
		select:  '#cat_id'
	};

	var dept = {
		ajax: '/widget/dept/getdept',
		selClass:'form-control inline',
		selStyle: 'font-size:12px;font-family:;microsoft YaHei;',
		autoLink : false,
		defVal: s.split(','),
		head: '请选择部门级别',
		select:  '#dept_id'
	};

	var linkageSel = new LinkageSel(opts);
	var linkageSe = new LinkageSel(dept);

	$('#search_button').click(function(){
		var v = linkageSel.getSelectedValue();
		var d = linkageSe.getSelectedValue();
		$('#select_cat_id').val(v);
		$('#select_dept_id').val(d);
	});

	$("#sync_all_user").bind("click", function(){
		var index  = layer.load(1, {
		  shade: [0.4,'#000'] //0.1透明度的白色背景
		});
		$.get("/system/user/sync", function(data){
			if (data == 'success') {
				layer.msg('同步成功', {
				  	icon: 1,
				  	time: 2000
				}, function(){
				 	window.location.reload();
				});   
			} else {
				var obj = eval('('+data+')');
				layer.alert(obj.message, function(){
					layer.closeAll();
				});
			}
		});
		return false;
	})
	
</script>
{/literal}
</body>
</html>
